package cn.edu.scau.cmi.liangzaoqing.client.classicsDesignPattern;

import java.util.Set;

import cn.edu.scau.cmi.liangzaoqing.composite.consistent.ConsistentComponent;
import cn.edu.scau.cmi.liangzaoqing.composite.consistent.ConsistentComposite;
import cn.edu.scau.cmi.liangzaoqing.composite.consistent.ConsistentLeaf;
import cn.edu.scau.cmi.liangzaoqing.composite.safe.SafeComponent;
import cn.edu.scau.cmi.liangzaoqing.composite.safe.SafeComposite;
import cn.edu.scau.cmi.liangzaoqing.composite.safe.SafeLeaf;

public class SafeCompositeClient {

	public static void main(String[] args) {
		
		
		
	//	组合件要么指定为组合件类型，要么仔细组合件的操作时，执行类型转换，否则将发生语法错误
		SafeComposite father=new SafeComposite();
		father.setName("父组件");
		SafeLeaf leaf=new SafeLeaf();
		leaf.setName("子组件");
		father.addChild(leaf);
		System.out.println(father.getName());
		
		Set<SafeComponent> children = father.getChildren();
		
		System.out.println(father.getChildren());
		
	}

}
